package com.jinzhi.jzcultivate.controller;

import com.jinzhi.common.annotation.Log;
import com.jinzhi.common.base.BaseController;
import com.jinzhi.jzapi.training.pojo.CoursesAndTeacherVo;
import com.jinzhi.jzweb.service.*;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@AllArgsConstructor
@RequestMapping("/couInfo")
public class CourseController extends BaseController {

	@Autowired
	private CoursesService coursesService;

	@Log("课程介绍")
	@GetMapping("/couInfo")
	String courseInfo(Model model , String id){
		CoursesAndTeacherVo coursesAndTeacherVo = coursesService.selCourseDetail(Long.parseLong(id));
		model.addAttribute("cou" , coursesAndTeacherVo);

		return "cultivateWeb/course/courseInfo";
	}


	@Log("课程搜索")
	@GetMapping("/courseSearch")
	String courseSearch(Model model,String name){
		model.addAttribute("name",name);
		return "cultivateWeb/course/courseSearch";
	}

	@Log("课程订单确认页面")
	@GetMapping("/courseSurePay")
	String courseSurePay(Model model, String orderId,String courseId,String type) {
        model.addAttribute("orderId", orderId);
        model.addAttribute("type", type);
		model.addAttribute("courseId", courseId);
		return "cultivateWeb/course/courseSurePay";
	}

    @Log("课程支付页面")
    @GetMapping("/coursePay")
    String coursePay(Model model,String courseOrderId,String courseAmount,String courseId){
        model.addAttribute("courseOrderId",courseOrderId);
        model.addAttribute("courseAmount",courseAmount);
		model.addAttribute("courseId",courseId);
        return "cultivateWeb/course/coursePay";
    }

	@Log("课程支付成功页面")
	@GetMapping("/coursePaySuccess")
	String coursePaySuccess(Model model,String courseOrderId,String courseId){
		model.addAttribute("courseOrderId",courseOrderId);
		model.addAttribute("courseId",courseId);
		return "cultivateWeb/course/coursePaySuccess";
	}
}
